<?php
require "model/new.model.php";
session_start();
if(isset($_SESSION['username'])){
    $title = $_POST["title"];
    $author = $_POST["author"];
    $content = $_POST["content"];
    $time = $_POST["date"];
    $addtime = strtotime($time);
    $kid = $_POST["modules"]; //获取这个分类的代号;               
    $content = htmlspecialchars($content,ENT_QUOTES);
    $tr = newList::addnew($title,$content,$author,$addtime,$kid);
    if($tr){
         echo "<script>alert('添加成功');parent.location.href='new.php';</script>";
    }else{        
         echo "<script>alert('添加失败');parent.location.href='./addarticle2.php?id=$id';</script>";
    }
}else{
     header("Location:./login.php");
     exit();
}